<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>设置</title>
    <style>
        /* 全局样式重置和基础设置 */
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
            background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
            color: #f5f5f7;
            padding: 24px;
            min-width: 320px;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
        }
        
        /* 设置容器 */
        .settings-container {
            width: 100%;
            max-width: 400px;
            background: rgba(255, 255, 255, 0.05);
            border-radius: 16px;
            backdrop-filter: blur(10px);
            -webkit-backdrop-filter: blur(10px);
            overflow: hidden;
            animation: fadeIn 0.5s ease-out;
        }
        
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        /* 设置头部 */
        .settings-header {
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 20px;
            font-weight: 600;
            padding: 16px 24px;
            text-align: center;
        }
        
        /* 设置内容 */
        .settings-content {
            padding: 24px;
        }
        
        /* 设置项 */
        .setting-item {
            margin-bottom: 20px;
            transition: transform 0.2s ease;
        }
        
        .setting-item:hover {
            transform: translateX(4px);
        }
        
        .setting-label {
            font-weight: 500;
            margin-bottom: 8px;
            display: block;
            color: #e0e0e0;
            font-size: 14px;
            letter-spacing: 0.5px;
        }
        
        /* 文本输入框样式 */
        .setting-control {
            width: 100%;
            padding: 12px 16px;
            background: rgba(255, 255, 255, 0.08);
            color: #f5f5f7;
            border-radius: 10px;
            font-size: 14px;
            transition: all 0.3s ease;
            outline: none;
            border: none;
        }
        
        .setting-control:focus {
            background: rgba(255, 255, 255, 0.1);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
        }
        
        .setting-control::placeholder {
            color: rgba(255, 255, 255, 0.5);
        }
        
        /* 下拉菜单样式修复 */
        .setting-select {
            width: 100%;
            padding: 12px 16px;
            background: rgba(255, 255, 255, 0.08);
            color: #f5f5f7;
            border-radius: 10px;
            font-size: 14px;
            transition: all 0.3s ease;
            outline: none;
            border: none;
            appearance: none;
            -webkit-appearance: none;
            background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23f5f5f7'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
            background-repeat: no-repeat;
            background-position: right 12px center;
            background-size: 16px;
            cursor: pointer;
        }
        
        .setting-select:focus {
            background-color: rgba(255, 255, 255, 0.1);
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
        }
        
        /* 设置底部按钮 */
        .settings-footer {
            margin-top: 32px;
            display: flex;
            gap: 12px;
        }
        
        .setting-button {
            flex: 1;
            padding: 12px 24px;
            border: none;
            border-radius: 10px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            position: relative;
            overflow: hidden;
        }
        
        .setting-button::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
            transition: all 0.6s ease;
        }
        
        .setting-button:hover::before {
            left: 100%;
        }
        
        .save-button {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .save-button:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
        }
        
        .save-button:active {
            transform: translateY(0);
        }
        
        .cancel-button {
            background: rgba(255, 255, 255, 0.1);
            color: #f5f5f7;
        }
        
        .cancel-button:hover {
            background: rgba(255, 255, 255, 0.15);
        }
        
        /* 响应式设计 */
        @media (max-width: 480px) {
            body {
                padding: 16px;
            }
            
            .settings-container {
                max-width: 100%;
            }
            
            .settings-content {
                padding: 16px;
            }
        }
        
        /* 添加焦点样式，增强可访问性 */
        .setting-button:focus {
            outline: none;
        }
    </style>
</head>
<body>
    <div class="settings-container">
        <div class="settings-header">应用设置</div>
        
        <div class="settings-content">
            <div class="setting-item">
                <label class="setting-label">用户称呼</label>
                <input type="text" class="setting-control" id="user-name" placeholder="请输入您的称呼">
            </div>
            
            <div class="setting-item">
                <label class="setting-label">用户性别</label>
                <select class="setting-select" id="user-gender">
                    <option value="male">男</option>
                    <option value="female">女</option>
                    <option value="other">其他</option>
                </select>
            </div>
            
            <div class="setting-item">
                <label class="setting-label">用户人设</label>
                <input type="text" class="setting-control" id="user-role" placeholder="请输入您的人设描述">
            </div>
            
            <div class="settings-footer">
                <button class="setting-button save-button" id="save-settings">保存设置</button>
                <button class="setting-button cancel-button" id="cancel-settings">取消</button>
            </div>
        </div>
    </div>
    
    <script>
        // 加载保存的设置
        function loadSettings() {
            try {
                const savedSettings = JSON.parse(localStorage.getItem('appSettings')) || {};
                document.getElementById('user-name').value = savedSettings.userName || '';
                document.getElementById('user-gender').value = savedSettings.userGender || 'male';
                document.getElementById('user-role').value = savedSettings.userRole || '';
            } catch (e) {
                console.error('加载设置失败:', e);
            }
        }
        
        // 保存设置
        function saveSettings() {
            const settings = {
                userName: document.getElementById('user-name').value,
                userGender: document.getElementById('user-gender').value,
                userRole: document.getElementById('user-role').value
            };
            
            try {
                localStorage.setItem('appSettings', JSON.stringify(settings));
                // 通知主窗口设置已保存
                if (window.opener) {
                    window.opener.postMessage({type: 'settings_saved', settings: settings}, '*');
                }
                
                // 显示更现代的保存成功提示
                const saveButton = document.getElementById('save-settings');
                const originalText = saveButton.textContent;
                saveButton.textContent = '已保存!';
                
                setTimeout(() => {
                    saveButton.textContent = originalText;
                    window.close();
                }, 1000);
            } catch (e) {
                console.error('保存设置失败:', e);
                alert('保存设置失败，请重试');
            }
        }
        
        // 取消设置
        function cancelSettings() {
            window.close();
        }
        
        // 绑定事件
        document.addEventListener('DOMContentLoaded', function() {
            loadSettings();
            
            document.getElementById('save-settings').addEventListener('click', saveSettings);
            document.getElementById('cancel-settings').addEventListener('click', cancelSettings);
            
            // ESC键关闭窗口
            document.addEventListener('keydown', function(e) {
                if (e.key === 'Escape') {
                    window.close();
                }
            });
        });
    </script>
</body>
</html>